import 'package:mc_card/model/shequ/article_item_model.dart';
import 'package:mc_card/model/shequ/banner_model.dart';
import 'package:mc_card/model/shequ/subject_model.dart';
import 'package:mc_card/model/shequ/topic_model.dart';

///
/// 推荐流 聚合Model
///
class RecommendModel {
  ///顶部Banner广告
  List<BannerModel> banners;

  ///推荐话题
  List<TopicModel> topics;

  ///page=1时候的feed流数据
  List<ArticleItemModel> articles;

  ///精选专题
  List<SubjectModel> feedSelections;

  RecommendModel({this.banners, this.topics, this.articles, this.feedSelections});

  factory RecommendModel.fromJson(Map<String, dynamic> json) {
    var localNavListJson = json['banners'] as List;
    List<BannerModel> bannerList = localNavListJson.map((i) => BannerModel.fromJson(i)).toList();

    var localTopicListJson = json['topics'] as List;
    List<TopicModel> topicList = localTopicListJson.map((i) => TopicModel.fromJson(i)).toList();

    var localArticleListJson = json['articles'] as List;
    List<ArticleItemModel> articleList = localArticleListJson.map((i) => ArticleItemModel.fromJson(i)).toList();

    var localSubjectListJson = json['feedSelections'] as List;
    List<SubjectModel> subjectList = localSubjectListJson.map((i) => SubjectModel.fromJson(i)).toList();

    return RecommendModel(banners: bannerList, topics: topicList, articles: articleList, feedSelections: subjectList);
  }
}
